package com.apes.scm.masterdata.product.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.product.model.Classify;
import com.apes.scm.masterdata.product.model.ServeCategory;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 功能：
 *
 * @Auther: linwz
 * @Date: 2018/8/10 16:52
 */
public interface ServeCategoryRepository extends CustomRepository<ServeCategory, String> {

    @Query(value = "SELECT distinct B.SERVE_TYPE_ID FROM MAS_SERVE_CATEGORY B, MAS_PRODUCT C\n" +
            "                              WHERE C.CLASSIFY_ID = B.CLASSIFY_ID AND C.ID = :product_id",nativeQuery = true)
    String findByProductId(@Param("product_id") String product_id);

    @Query(value = "select a.classify_id from mas_serve_category a where a.serve_type_id = :serveTypeId", nativeQuery = true)
    List<String> findByClassify(String serveTypeId);
}
